package com.springboot.chapter1;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class TestController {
	@Value("${db.url}")
	private String url;
	@Value("${db.username}")
	private String user;
	@Value("${db.password}")
	private String password;

	@GetMapping("/test")
	public String test(){
		String str="<h1>当前环境连接的数据库URL："+url+"</h1>";
		str+="<h1>数据库用户："+user+"</h1>";
		str+="<h1>密码："+password+"</h1>";
		return str;
	}
	@GetMapping("")
	public String getUsers(){
		System.out.println("查询所有用户");
		return "查询所有用户成功";
	}
	@GetMapping("/{id}")
	public String getUser(@PathVariable Integer id){
		System.out.println("查询用户信息id="+id);
		return "查询用户信息id成功";
	}
	@PutMapping("/{id}")
	public String update(@PathVariable Integer id){
		System.out.println("修改用户信息"+id);
		return "修改用户信息成功";
	}
	@DeleteMapping("/{id}")
	public String delete(@PathVariable Integer id){
		System.out.println("删除用户信息" + id);
		return "删除用户信息";
	}
}
